$(function () {
	getfjqysl();
	getfjspnl();
	getfjspdj();
   // echart_map();
	getfjspfw();
	/*echart_6();
	echart_8();
	echart_9();
	echart_7();*/
	getndspzs();
	getfjsplx();
    //echart_1湖南货物收入
	
	
	function getfjqysl(){
		 $.ajax({
				url : "/sys/clFjspInfo/getfjqysl",
				contentType : "application/json",
	         	dataType : 'json',
				data : JSON.stringify(),
	          	type:'post',
				success : function(data) {
					 echart_1(data.data);
				
				}
			}); 
}
	function getfjspnl(){
		 $.ajax({
				url : "/sys/clFjspInfo/getfjspnl",
				contentType : "application/json",
	         	dataType : 'json',
				data : JSON.stringify(),
	          	type:'post',
				success : function(data) {
					 echart_2(data.data);
				
				}
			}); 
}
	function getndspzs(){
		 $.ajax({
				url : "/sys/clFjspInfo/getndspzs",
				contentType : "application/json",
	         	dataType : 'json',
				data : JSON.stringify(),
	          	type:'post',
				success : function(data) {
					 echart_10(data.data);
				
				}
			}); 
}
	function getfjsplx(){
		 $.ajax({
				url : "/sys/clFjspInfo/getfjsplx",
				contentType : "application/json",
	         	dataType : 'json',
				data : JSON.stringify(),
	          	type:'post',
				success : function(data) {
					 echart_11(data.data);
				
				}
			}); 
}
	function getfjspdj(){
		 $.ajax({
				url : "/sys/clFjspInfo/getfjspdj",
				contentType : "application/json",
	         	dataType : 'json',
				data : JSON.stringify(),
	          	type:'post',
				success : function(data) {
					 echart_3(data.data);
				
				}
			}); 
}
	function getfjspfw(){
		 $.ajax({
				url : "/sys/clFjspInfo/getfjspfw",
				contentType : "application/json",
	         	dataType : 'json',
				data : JSON.stringify(),
	          	type:'post',
				success : function(data) {
					 echart_4(data.data);
				
				}
			}); 
}
    function echart_1(list) {
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('chart_1'));
        var app = {};
		var option;
		var arr=[];
		 for(var i=0;i<list.length;i++){
			// if(list[i].name!="1" && list[i].name!="2" && list[i].name!="8"){
			 arr.push([list[i].qy,list[i].sl])
			// }
		 }
	option = {
		tooltip: {
			trigger: 'item',
			formatter: ' {c} '
		},
		dataset: [{
			dimensions: ['name', 'score'],
			source: arr
		}, {
			transform: {
				type: 'sort',
				config: { dimension: 'score', order: 'desc' }
			}
		}],
		xAxis: {
			type: 'category',
			axisLabel: { interval: 0, rotate: 40 },
			axisLine: {
					lineStyle: {
						color: "#333",
					}
				}
		},
		yAxis: {
			axisLine: {
					lineStyle: {
						color: "#333",
					}
				}
		},
	
		series: {
			type: 'bar',
			encode: { x: 'name', y: 'score' },
			 itemStyle: {
						normal: {
			　　　　　　　　//这里是重点
							color: function(params) {
								//注意，如果颜色太少的话，后面颜色不会自动循环，最好多定义几个颜色
								var colorList = [ '#61a0a8', '#d48265', '#91c7ae','#749f83', '#ca8622','#c23531','#d48265'];
								return colorList[params.dataIndex]
							}
						}
					}
			
		}
	};

	if (option && typeof option === 'object') {
		myChart.setOption(option);
	}
    }

    //电子商务销售额、订单数
    function echart_2(list) {
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('chart_2'));
        var app = {};
		var arr=[];
		for (var i = 0; i < list.length; i++) {
			arr.push([list[i].name,list[i].value]);
		}
		var option;
	option = {
		tooltip: {
			trigger: 'item',
			formatter: ' {c} '
		},
		dataset: [{
			dimensions: ['name', 'score'],
			source: arr
		}, {
			transform: {
				type: 'sort',
				config: { dimension: 'score', order: 'desc' }
			}
		}],
		xAxis: {
			type: 'category',
			axisLabel: { interval: 0, rotate: 30 },
			axisLine: {
					lineStyle: {
						color: "#333",
					}
				}
		},
		yAxis: {
			axisLine: {
					lineStyle: {
						color: "#333",
					}
				}
		},
		series: {
			type: 'bar',
			encode: { x: 'name', y: 'score' },
			 itemStyle: {
						normal: {
			　　　　　　　　//这里是重点
							color: function(params) {
								//注意，如果颜色太少的话，后面颜色不会自动循环，最好多定义几个颜色
								var colorList = ['#c23531','#2f4554', '#61a0a8', '#d48265', '#91c7ae','#749f83', '#ca8622','#c23531','#d48265'];
								return colorList[params.dataIndex]
							}
						}
					}
			
		}
	};

	if (option && typeof option === 'object') {
		myChart.setOption(option);
	}
    }


    //echart_3货物周转量
    function echart_3(list) {
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('chart_3'));
        var app = {};
		var arr=[];
		for (var i = 0; i < list.length; i++) {
			arr.push([list[i].cjdj,list[i].sl]);
		}
		var option;
	option = {
		tooltip: {
			trigger: 'item',
			formatter: ' {c} '
		},
		dataset: [{
			dimensions: ['name', 'score'],
			source: arr
		}, {
			transform: {
				type: 'sort',
				config: { dimension: 'score', order: 'desc' }
			}
		}],
		xAxis: {
			type: 'category',
			axisLabel: { interval: 0, rotate: 30 },
			axisLine: {
					lineStyle: {
						color: "#333",
					}
				}
		},
		yAxis: {
			axisLine: {
					lineStyle: {
						color: "#333",
					}
				}
		},
		series: {
			type: 'bar',
			encode: { x: 'name', y: 'score' },
			 itemStyle: {
						normal: {
			　　　　　　　　//这里是重点
							color: function(params) {
								//注意，如果颜色太少的话，后面颜色不会自动循环，最好多定义几个颜色
								var colorList = ['#c23531','#2f4554', '#61a0a8', '#d48265', '#91c7ae','#749f83', '#ca8622','#c23531','#d48265'];
								return colorList[params.dataIndex]
							}
						}
					}
			
		}
	};

	if (option && typeof option === 'object') {
		myChart.setOption(option);
	}
        
    }
	
	function echart_4(list) {
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('chart_4'));
        var arr=[];
        var arr1=[];
		for (var i = 0; i < list.length; i++) {
			arr.push(list[i].name);
			arr1.push(list[i].sl);
		}
        option = {
        		   tooltip: {
                       trigger: 'item',
                       formatter: "{b} : {c}人"
                   },	
        		xAxis: {
        	        type: 'category',
        	        data: arr,
        	        axisLabel: {  
                 	   interval:0,  
                 	   rotate:40  
                 	}
        	    },
        	    yAxis: {
        	        type: 'value'
        	    },
        	    series: [{
        	        data: arr1,
        	        type: 'bar'
        	    }]
        };
        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
        window.addEventListener("resize", function () {
            myChart.resize();
        });
    }


	

		 function echart_10(list) {
		        // 基于准备好的dom，初始化echarts实例
		        var myChart = echarts.init(document.getElementById('chart_10'));
		       
		        var arr=[];
		        var arr1=[];
				 for(var i=0;i<list.length;i++){
				 arr.push(list[i].nf+"年");
				 arr1.push(list[i].sl);
				 }
		        myChart.clear();
		        option = {
		            title: {
		                text: ''
		            },
		            tooltip: {
		                trigger: 'axis'
		            },
		            legend: {
		                data:['辅具适配总数'],
		                textStyle:{
		                    color: '#333'
		                },
		                top: '8%'
		            },
		            grid: {
		                top: '40%',
		                left: '3%',
		                right: '7%',
		                bottom: '3%',
		                containLabel: true
		            },
		            color: ['#FF4949','#FFA74D','#FFEA51','#4BF0FF','#44AFF0','#4E82FF','#584BFF','#BE4DFF','#F845F1'],
		            xAxis: {
		                type: 'category',
		                boundaryGap: false,
		                data: arr,
		                splitLine: {
		                    show: false
		                },
		                axisLine: {
		                    lineStyle: {
		                        color: '#333'
		                    }
		                }
		            },
		            yAxis: {
		                name: '',
		                type: 'value',
		                splitLine: {
		                    show: false
		                },
		                axisLine: {
		                    lineStyle: {
		                        color: '#333'
		                    }
		                }
		            },
		            series: [
		                {
		                    name:'辅具适配总数',
		                    type:'line',
		                    data:arr1
		                }
		                
		            ]
		        };
		        myChart.setOption(option);
		    }


		    //echart_3货物周转量
		    function echart_11(list) {
		        // 基于准备好的dom，初始化echarts实例
		        var myChart = echarts.init(document.getElementById('chart_11'));
		        console.log(list)
		      	var arr=[];
		       	arr.push(['score', 'number', 'product']);
		    	 for(var i=0;i<list.length;i++){       
		    		
		    		 arr.push([(i+1)*10,list[i].sl,list[i].cjlx])
		    	
		    	 }
		    			var app = {};
		    			var option;

		    			option = {
		    				 tooltip: {
		                    trigger: 'item',
		                    formatter: "色度,人数，类型<br/>{c} "
		                },
		    				dataset: {	
		    					source: arr
		    					
		    				},
		    				    grid: {
		                  
		                    left: '3%',
		                    right: '15%',
		                  
		                    containLabel: true
		                },
		    				xAxis: {name: 'number', axisLine: {
		    						lineStyle: {
		    							color: "#333",
		    						}
		    					}},
		    				yAxis: {type: 'category', axisLine: {
		    						lineStyle: {
		    							color: "#333",
		    						}
		    					}},
		    				visualMap: {
		    					orient: 'horizontal',
		    					left: 'center',
		    					min: 10,
		    					max: 100,
		    					text: ['High Score', 'Low Score'],
		    					// Map the score column to color
		    					dimension: 0,
		    					inRange: {
		    						color: ['#65B581', '#FFCE34', '#FD665F']
		    					},
		    					 textStyle:{
		    					color:"#333"
		    				}
		    				},
		    				series: [
		    					{
		    						type: 'bar',
		    						encode: {
		    							// Map the "number" column to X axis.
		    							x: 'number',
		    							// Map the "product" column to Y axis
		    							y: 'product'
		    						}
		    						

		    					}
		    				]
		    			};

		    			if (option && typeof option === 'object') {
		    				myChart.setOption(option);
		    			}
		    }
    //点击跳转
    // $('#chart_map').click(function(){
    //     window.location.href = './page/index.html';
    // });
    // $('.t_btn2').click(function(){
    //     window.location.href = "./page/index.html?id=2";
    // });
    // $('.t_btn3').click(function(){
    //     window.location.href = "./page/index.html?id=3";
    // });
    // $('.t_btn4').click(function(){
    //     window.location.href = "./page/index.html?id=4";
    // });
    // $('.t_btn5').click(function(){
    //     window.location.href = "./page/index.html?id=5";
    // });
    // $('.t_btn6').click(function(){
    //     window.location.href = "./page/index.html?id=6";
    // });
    // $('.t_btn7').click(function(){
    //     window.location.href = "./page/index.html?id=7";
    // });
    // $('.t_btn8').click(function(){
    //     window.location.href = "./page/index.html?id=8";
    // });
    // $('.t_btn9').click(function(){
    //     window.location.href = "./page/index.html?id=9";
    // });
});
